package com.example.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.example.contant.MessageConstant;
import com.example.entity.PageResult;
import com.example.entity.QueryPageBean;
import com.example.entity.Result;
import com.example.service.CommentsService;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/comments")
@RestController
public class CommentsController {
    @Reference
    private CommentsService commentsService;
    @PostMapping("/findpage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return commentsService.findpage(queryPageBean);
    }
    @GetMapping("/delete")
    public Result delete(Integer id){

        try{
            commentsService.deleteById(id);
        }catch (Exception e){
            e.printStackTrace();
            return  new Result(false, MessageConstant.DELETE_COMMENTS_FAIL);
        }
        return new Result(true,MessageConstant.DELETE_COMMENTS_SUCCESS);
    }
}
